package com.eastedu.converter;

import com.eastedu.model.ktree.BasicResourceKnowledgeJsonSerializableDTO;
import com.eastedu.model.ktree.KnowledgeNodeDTO;
import com.eastedu.repository.basic.po.BasicResourceKnowledgePO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingConstants;
import org.mapstruct.MappingTarget;

/**
 * The interface Basic resource file converter.
 *
 * @author zhangzhishuai
 */
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
public interface BasicResourceKnowledgeConverter {

    /**
     * Update.
     *
     * @param dto the dto
     * @param po  the po
     */
    @Mapping(target = "knowledgeRootName", source = "rootName")
    @Mapping(target = "knowledgeRootId", source = "rootGuid")
    @Mapping(target = "knowledgeName", source = "nodeName")
    @Mapping(target = "knowledgeId", source = "nodeGuid")
    @Mapping(target = "id", ignore = true)
    @Mapping(target = "createTime", ignore = true)
    @Mapping(target = "basicResourceId", ignore = true)
    @Mapping(target = "updateTime", ignore = true)
    void update(KnowledgeNodeDTO dto, @MappingTarget BasicResourceKnowledgePO po);

    /**
     * To serializable dto basic resource knowledge json serializable dto.
     *
     * @param po the po
     * @return the basic resource knowledge json serializable dto
     */
    BasicResourceKnowledgeJsonSerializableDTO toSerializableDTO(BasicResourceKnowledgePO po);
}
